
a = [0] * 20
N = int(input())
col = [False] * 20
lt = [False] * 40
rt = [False] * 40
cnt = 0


def backtracking(step):
    global a, used, n, cnt, col, lt, rt;
    if step == N + 1:
        cnt += 1
        for i in range(1, N + 1):
            print('%5d' % a[i], end='')
        print()
        return
    for i in range(1, N + 1):
        if not col[i] and not lt[step + i] and not rt[step - i]:
            a[step] = i
            col[i], lt[step + i], rt[step - i] = True, True, True
            backtracking(step + 1)
            col[i], lt[step + i], rt[step - i] = False, False, False
backtracking(1)
if cnt == 0:
    print('no solute!')
